<?php
include_once ('bd/ModeloBD.php');

class ModeloRanking extends ModeloBD {

    private $idranking;
    private $idtorneo;
    private $idcategoria;
    private $ranpuesto;
    private $ranobservacion;
    private $ranestado;
    
    public function __construct($idranking = "", $idtorneo = "", $idcategoria = "", $ranpuesto = "", $ranobservacion = "", $ranestado = "") {
        $this->_oBaseDatos = CBaseDatos::get_instancia();
        $this->_oBaseDatos->conectar();
        $this->_sTabla = "ranking";
        $this->idranking= $idranking;
        $this->idtorneo = $idtorneo;
        $this->idcategoria = $idcategoria;
	$this->ranpuesto = $ranpuesto;
	$this->ranobservacion = $ranobservacion;
	$this->ranestado = $ranestado;
	
    }

    public function listaRanking() {
        $arRanking = null;
        $sSQL = "
            SELECT  a.*, b.catnombre,c.modnombre,( SELECT count( e.idcategoria) FROM usuario e WHERE e.idcategoria = b.idcategoria GROUP BY b.idcategoria) AS jugadores
            FROM $this->_sTabla a, categoria b, modalidad c where a.idcategoria=b.idcategoria and b.idmodalidad=c.idmodalidad";
        $arRanking = $this->query_object($sSQL);
        return $arRanking;
    }
    public function listaJugadores($idranking) {
        $arRanking = null;
        $sSQL = "
            SELECT  b.*
            FROM $this->_sTabla a, usuario b where a.idranking=b.idranking and b.idranking=$idranking  Order By b.usupuntos desc";
        $arRanking = $this->query_object($sSQL);
        return $arRanking;
    }

}

?>
